﻿using System.Runtime.Remoting.Contexts;
using UnityEngine;
using UnityEngine.UI;

public class UserIconItem : MonoBehaviour
{
    public Text nameText;
    public Text birthYear;
    public Text locationCity;
    public Text height;
    public NetworkImage iconTex;

    Texture2D m_Texture;

    public void Init(string name, int birthYear,string locationCity,int height,string icon)
    {
        if (m_Texture)
            DestroyImmediate(m_Texture);

        iconTex.Init(icon);

        if (this.nameText)
            nameText.text = name;
        if (this.birthYear)
            this.birthYear.text = (birthYear % 1900) + "年";
        if (this.locationCity)
            this.locationCity.text = "现居" + locationCity.Replace("市","");
        if (this.height)
            this.height.text = height + "cm";
    }

    void OnDestroy()
    {
        if (m_Texture)
            DestroyImmediate(m_Texture);
    }
}
